﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Collections;
using System.Collections.Specialized;

public partial class DirectDataSource : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        IDataSource ds = this.ObjectDataSource1 as IDataSource;
        DataSourceView dsv = ds.GetView(string.Empty);

        DataSourceSelectArguments dssa = new DataSourceSelectArguments();

        dsv.Select(
            dssa,
            delegate(IEnumerable data)
            {
                // 使用数据
                this.GridView1.DataSource = data;
                this.GridView1.DataBind();
            }
        );

    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
IDataSource ds = this.ObjectDataSource1 as IDataSource;
DataSourceView dsv = ds.GetView(string.Empty);

Hashtable keys = new Hashtable();
Hashtable values = new Hashtable();
Hashtable oldValues = new Hashtable();

keys.Add("ProductCategoryID", "3");
values.Add("Name", "Cloths");

dsv.Update(
    keys,
    values,
    oldValues,
    delegate(int affectedRecords, Exception ex)
    {
        return true;
    }
    );

    }
}